// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-__proto__-property-names-in-object-initializers
description: >
  The value of the `__proto__` property key is assigned to the [[Prototype]].
  Object.prototype.__proto__ setter should not be called.
info: |
  __proto__ Property Names in Object Initializers

  PropertyDefinition : PropertyName : AssignmentExpression

  [...]
  7. If isProtoSetter is true, then
    a. If Type(propValue) is either Object or Null, then
      i. Return object.[[SetPrototypeOf]](propValue).
---*/

function Test() {
    Object.defineProperty(Object.prototype, '__proto__', {
      set: function() {
        throw new Test262Error('should not be called');
      },
    });

    var proto = {};

    var object = {
      __proto__: proto
    };

    assert(!object.hasOwnProperty('__proto__'));
    assert.sameValue(Object.getPrototypeOf(object), proto);
}

// preheat
const NUMBER_OF_PREHEAT = 1;
for (let i = 0; i < NUMBER_OF_PREHEAT; i++) {
    Test();
}

ArkTools.jitCompileAsync(Test);
assert.sameValue(ArkTools.waitJitCompileFinish(Test), true, '[JIT] JIT disabled.');

// test
const NUMBER_OF_TEST = 1; // or 2
for (let i = 0; i < NUMBER_OF_TEST; i++) {
    Test();
}
